<?php
namespace Site\Controller;
class ParseController extends CommonController {
    public function index() {
        $data = $this->getPageList(M('Parse'),array(),'createtime desc');
        $this->display();
    }

    public function add() {
        if(IS_POST) {
            D('Parse','Mysql')->addParse(array_merge(I('post.'),array(
                'config'    =>  $_POST['config'],
            )));
            $this->success('解析器添加成功','/Parse');
        }
        $this->display();
    }

    public function update() {
        if(IS_POST) {
            D('Parse','Mysql')->updateParse(array_merge(I('post.'),array(
                'config'    =>  $_POST['config'],
            )));
            $this->success('解析器修改成功','/Parse');
        }else {
            $id = I('get.id');
            verify($id,'isID','非法解析器ID');

            $parseInfo = M('Parse')->find($id);
            verify($parseInfo,'notEmpty','解析器不存在');

            $this->assign('parseInfo',$parseInfo);
            $this->display();
        }
    }
}
?>
